/* -----------------------------------------------------------
 * Author: Maria Powell
 * Testing Function: scoreFor()
 * Function Description: This function determines the scores of
 * 						 each player.
 * What to test: Since unit test "unittest3" failed because of 
 * 				scorefor() function, this unit test will test
 * 				if deck score gets returned properly of two
 * 				players. 
 * How to test: I will set up the game state and with scores
 * 				and compare if the right scores get returned.
 -----------------------------------------------------------*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//Set NOISY test to 0 to remove printfs from output console
#define NOISY_TEST 1

int main()
{
	//Initialization
	int i = 0;
	int seed = 1000;
	int numPlayers = 2;
	int firstPlayer = 0;
	int secondPlayer = 1;
	int province1 = 2;
	int province2 = 3;
	int shouldBeScore = 18;
	int returnScore = 0;
	int players[MAX_PLAYERS];
	int k[10] = {adventurer, council_room, feast, gardens, mine,
				 remodel, smithy, village, baron, great_hall};
	struct gameState G;
	int winner = 1;

	printf("TESTING  scoreFor()\n");
	#if (NOISY_TEST == 1)
		printf("Setting gameState Values:\n");
		printf("First Player Score = 12\n");
		printf("Second Player Score = 18\n");
	#endif

	//clear gameState
	memset(&G, 23, sizeof(struct gameState)); 
	
	//setting up gameState and scores for players
	initializeGame(numPlayers, k, seed, &G); 
	G.whoseTurn = secondPlayer;	

	G.deckCount[firstPlayer] = 2;
	G.deckCount[secondPlayer] = 3;
	for(i = 0; i <  province1; i++)    //set province card number
	{
		G.deck[firstPlayer][i] = province;
	}
	for(i = 0; i < province2; i++)
	{
		G.deck[secondPlayer][i] = province;
	}

	#if (NOISY_TEST == 1)	
	printf("Calling scoreFor():\n");
	#endif
	
	returnScore = scoreFor(secondPlayer, &G);
	printf("returnScore= %d\n", returnScore);
	assert(returnScore == shouldBeScore);

	printf("Unit Test passed.\n");


}
